package com.fdb.efp.nls.service.common.rules.apply;

import com.fdb.basic.framework.core.constant.EsbRetCodeStandard;
import com.fdb.basic.framework.core.exception.BizException;
import com.fdb.efp.nls.service.common.rules.CheckRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

/**
 * 需求编号:2019D08--
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2020/1/17
 * 功能描述:
 * 修改日期:2020/1/17
 * 修改描述:
 */
public class ValidateAvailAmtAndLoanAmt implements CheckRule {
    private static Logger logger = LoggerFactory.getLogger(ValidateAvailAmtAndLoanAmt.class);

    private BigDecimal availAmt;
    private BigDecimal loanAmt;
    private String applyNo;

    public ValidateAvailAmtAndLoanAmt(BigDecimal availAmt, BigDecimal loanAmt,String applyNo) {
        this.availAmt = availAmt;
        this.loanAmt = loanAmt;
        this.applyNo = applyNo;
    }


    @Override
    public void check() throws BizException {
        if (loanAmt.compareTo(availAmt) > 0){
            logger.error("用信申请流水号【" + applyNo + "】，贷款额度大于可用额度！");
            throw new BizException(EsbRetCodeStandard.WFJKYWGZ.getValue(), "用信申请流水号【" + applyNo+ "】，贷款额度大于可用额度！");
        }
    }
}
